/*
 *Copyright (c) 2024 Black Sesame Technologies
 *
 *Licensed under the Apache License, Version 2.0 (the "License");
 *you may not use this file except in compliance with the License.
 *You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 *Unless required by applicable law or agreed to in writing, software
 *distributed under the License is distributed on an "AS IS" BASIS,
 *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *See the License for the specific language governing permissions and
 *limitations under the License.
*/

#ifndef HSCG_INTERFACECONFIG_H
#define HSCG_INTERFACECONFIG_H

#ifdef __cplusplus
extern "C" {
#endif


/*==================================================================================================
 *                                        INCLUDE FILES
 * 1) system and project includes
 * 2) needed interfaces from external units
 * 3) internal and external interfaces from this unit
 ==================================================================================================*/
#include "StandardTypes.h"

/*==================================================================================================
 *                              SOURCE FILE VERSION INFORMATION
 ==================================================================================================*/

/*==================================================================================================
 *                                     FILE VERSION CHECKS
 ==================================================================================================*/

/*==================================================================================================
 *                                          CONSTANTS
 ==================================================================================================*/

/*==================================================================================================
 *                                      DEFINES AND MACROS
 ==================================================================================================*/

/* HSCG base addresses*/
/** @brief Base address for the RXIN FIFO used by the channel 0. */
#define HSCG_RXIN0_BASEADDR ((uint32)0x43A00000UL)
/** @brief Base address for the RXOUT FIFO used by the channel 0. */
#define HSCG_RXOUT0_BASEADDR ((uint32)0x43A08000UL)
/** @brief Base address for the BLRIN FIFO used by the channel 0. */
#define HSCG_BLRIN0_BASEADDR ((uint32)0x43B00000UL)
/** @brief Base address for the BLROUT FIFO used by the channel 0. */
#define HSCG_BLROUT0_BASEADDR ((uint32)0x43B08000UL)
/** @brief Base address for the TXACK FIFO used by the channel 0. */
#define HSCG_TXACK0_BASEADDR ((uint32)0x43B10000UL)
/** @brief Base address for Generic FIFO 0. */
#define HSCG_GENERIC_FIFO_BASEADDR ((uint32)0x43A12000UL)
/** @brief Base address for the CORE2CORE module. */
#define HSCG_CORE2CORE_BASEADDR ((uint32)0x43C26000UL)
/** @brief Base address for the interrupt concentrator registers. */
#define HSCG_ICSR_BASEADDR ((uint32)0x43A14000UL)

/* HSCG configuration parameters.*/
/**
 * @brief Default controller ID needed by the host 0 interface in order to
 * transmit INIT_PLATFORM and DEINIT_PLATFORM commands from host to HSCG.
 */
#define HSCG_CAN_CONFIG_DEFAULT_CAN_CTRL_HOST0_U8 (uint8)0U
/**
 * @brief Default controller ID needed by the host 1 interface in order to
 * transmit INIT_PLATFORM and DEINIT_PLATFORM commands from host to HSCG.
 */
#define HSCG_CAN_CONFIG_DEFAULT_CAN_CTRL_HOST1_U8 (uint8)8U

/**
 * @brief Maximum number of notifications which can be reported by HSCG
 * to host.
 */
#define HSCG_CAN_CONFIG_NOTIF_TABLE_SIZE 17U
/**
 * @brief Maximum buffer size used to store the CAN FD frame payload.
 * See \link Hscg_Can_MbType \endlink
 */
#define HSCG_CAN_CONFIG_PAYLOAD_MAX_SIZE 64U
/**
 * @brief Maximum number of hardware controllers usable inside HSCG.
 * See \link Hscg_Can_InitCmdType \endlink
 */
#define HSCG_CAN_CONFIG_MAXCTRL_COUNT 16U
/**
 * @brief Maximum number of hardware controllers usable inside HSCG.
 * See \link Hscg_Can_InitCmdType \endlink
 */
#define HSCG_CAN_MAX_POLLING_CLASSES 6U

#define HSCG_CAN_MAX_MB_COUNT   56U

/**
 * @brief Maximum number of transmission message buffers.
 * See \link Hscg_Can_TxMbDescriptorType \endlink
 */
#define HSCG_CAN_CONFIG_MAXTXMB 64U
/**
 * @brief Maximum number of reception message buffers.32 from those are reserved
 * for internal usage and are not available to the host.
 * See \link Hscg_Can_RxMbDescriptorType \endlink
 */
#define HSCG_CAN_CONFIG_MAXRXMB 64U
#define HSCG_CAN_CONFIG_MAXAFRXMB 64U
#define HSCG_CAN_CONFIG_MAXAFTXMB 64U
#define HSCG_CAN_CONFIG_MAXAFFRMB 64U

/**
 * @brief Maximum number of standard filters which can be configured using
 * using a single command. Multiple commands can be executed when more filters
 * are needed.
 * See \link Hscg_Can_ReceiveFilterType \endlink
 */
#define HSCG_CAN_CONFIG_MAX_FILTERS_COUNT ((uint16)20U)
/**
 * @brief Number of entries of the circular buffer used to send ack information
 * from TX core to host core. There is 1 extra buffer for each interface for
 * consistency purpose.
 */
#define HSCG_CAN_CONFIG_MAX_TXACKINFO ((uint16)(64U + HSCG_CAN_RX_TX_INTERFACES))
/**
 * @brief Mask used to get the right data from FIFOs.
 * See FMR config register of FIFO.
 */
#define HSCG_CAN_CONFIG_FIFO_FIXED_MASK_U32 ((uint32)0x0007FFFF)
/**
 * @brief Maximum number of advanced filters which can be configured using a
 * single command. Multiple commands can be executed when more filters are
 * needed.
 * See \link Hscg_Can_AdvancedFilterType \endlink
 */
#define HSCG_CAN_CONFIG_ADVANCED_FILTERS_COUNT 8U
/**
 * @brief Shared memory size allocated for each channel for
 * commands exchange.
 */
#define HSCG_CAN_CONFIG_CTRL_SHARED_MEMORY_SIZE (uint32)0x400
/**
 * @brief Reserved value in order to detect if an advanced filter entry
 * is not used.
 */
#define HSCG_CAN_ADVANCED_FILTER_NOT_USED 0xFFU
/** @brief Interface ID used by different hosts for multihost scenarios. */
#define HSCG_CAN_HIF0 0U
/** @brief Interface ID used by different hosts for multihost scenarios. */
#define HSCG_CAN_HIF1 1U
/** @brief Number of interfaces which can be used by host cores. */
#define HSCG_CAN_CONFIG_HIF_COUNT 2U
/**
 * @brief Number of ocurrences of last error reported by the notification
 * mechanism.Limited by \link Hscg_Can_ErrorNotifType \endlink structure size.
 */
#define HSCG_CAN_CONFIG_MAX_OCCURENCES 255U

/* LIN defines */
/** @brief Maximum buffer size used to store the LIN frame payload */
#define HSCG_LIN_CONFIG_PAYLOAD_MAX_SIZE 8U
/** @brief Maximum number of LIN transmission buffers */
#define HSCG_LIN_CONFIG_MAXTXBUFF 64U
/** @brief Maximum number of LIN reception buffers */
#define HSCG_LIN_CONFIG_MAXRXBUFF 64U

/*==================================================================================================
 *                                      Interrupts
 ==================================================================================================*/

/*==================================================================================================
 *                                             ENUMS
 ==================================================================================================*/

/*==================================================================================================
 *                                STRUCTURES AND OTHER TYPEDEFS
 ==================================================================================================*/

/*==================================================================================================
 *                                GLOBAL VARIABLE DECLARATIONS
 ==================================================================================================*/

/*==================================================================================================
 *                                    FUNCTION PROTOTYPES
 ==================================================================================================*/

#ifdef __cplusplus
}
#endif

#endif /* HSCG_FIFO_H */

/** @} */
